package org.jeecg.modules.meter.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.jeecg.modules.meter.entity.MeterRoom;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Description: 水电表房间绑定
 * @Author: jeecg-boot
 * @Date:   2019-12-05
 * @Version: V1.0
 */
@Repository
public interface MeterRoomMapper extends BaseMapper<MeterRoom> {

    @Select("select * from meter_room where meter_id = #{meterId} and room_id=#{roomId} and del_flag = '0'")
    MeterRoom getMeterRoom(@Param("meterId") String meterId, @Param("roomId") String roomId);

    @Update("UPDATE meter_room SET del_flag = 1, update_time = now(), update_by = #{userId} WHERE meter_id = #{meterId} AND room_id = #{oldRoomId}")
    void deleteMeterRoom(@Param("meterId") String meterId, @Param("oldRoomId") String oldRoomId, @Param("userId") String userId);

    MeterRoom selectByMeterId(@Param("meterId") String id);

    List<MeterRoom> queryOldMeterAddress(@Param("meterId") String id);
}
